Optimal. Leaf size=46 \[ (a-b)^2 x+\frac {(2 a-b) b \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.02, antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps
used = 4, number of rules used = 3, integrand size = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {3742, 398, 209}
\begin {gather*} \frac {b (2 a-b) \tan (e+f x)}{f}+x (a-b)^2+\frac {b^2 \tan ^3(e+f x)}{3 f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 209
Rule 398
Rule 3742
Rubi steps
\begin {align*} \int \left (a+b \tan ^2(e+f x)\right )^2 \, dx &=\frac {\text {Subst}\left (\int \frac {\left (a+b x^2\right )^2}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {\text {Subst}\left (\int \left ((2 a-b) b+b^2 x^2+\frac {(a-b)^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(2 a-b) b \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f}+\frac {(a-b)^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f}\\ &=(a-b)^2 x+\frac {(2 a-b) b \tan (e+f x)}{f}+\frac {b^2 \tan ^3(e+f x)}{3 f}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.38, size = 73, normalized size = 1.59 \begin {gather*} \frac {\tan (e+f x) \left (\frac {3 (a-b)^2 \tanh ^{-1}\left (\sqrt {-\tan ^2(e+f x)}\right )}{\sqrt {-\tan ^2(e+f x)}}+b \left (6 a-b \left (3-\tan ^2(e+f x)\right )\right )\right )}{3 f} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.00, size = 59, normalized size = 1.28
method | result | size |
norman | \(\left (a^{2}-2 a b +b^{2}\right ) x +\frac {\left (2 a -b \right ) b \tan \left (f x +e \right )}{f}+\frac {b^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3 f}\) | \(49\) |
derivativedivides | \(\frac {\frac {b^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3}+2 a b \tan \left (f x +e \right )-b^{2} \tan \left (f x +e \right )+\left (a^{2}-2 a b +b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(59\) |
default | \(\frac {\frac {b^{2} \left (\tan ^{3}\left (f x +e \right )\right )}{3}+2 a b \tan \left (f x +e \right )-b^{2} \tan \left (f x +e \right )+\left (a^{2}-2 a b +b^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{f}\) | \(59\) |
risch | \(x \,a^{2}-2 x a b +x \,b^{2}-\frac {4 i b \left (-3 a \,{\mathrm e}^{4 i \left (f x +e \right )}+3 b \,{\mathrm e}^{4 i \left (f x +e \right )}-6 a \,{\mathrm e}^{2 i \left (f x +e \right )}+3 b \,{\mathrm e}^{2 i \left (f x +e \right )}-3 a +2 b \right )}{3 f \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )^{3}}\) | \(92\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.49, size = 63, normalized size = 1.37 \begin {gather*} a^{2} x - \frac {2 \, {\left (f x + e - \tan \left (f x + e\right )\right )} a b}{f} + \frac {{\left (\tan \left (f x + e\right )^{3} + 3 \, f x + 3 \, e - 3 \, \tan \left (f x + e\right )\right )} b^{2}}{3 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 4.13, size = 53, normalized size = 1.15 \begin {gather*} \frac {b^{2} \tan \left (f x + e\right )^{3} + 3 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} f x + 3 \, {\left (2 \, a b - b^{2}\right )} \tan \left (f x + e\right )}{3 \, f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [A]
time = 0.10, size = 68, normalized size = 1.48 \begin {gather*} \begin {cases} a^{2} x - 2 a b x + \frac {2 a b \tan {\left (e + f x \right )}}{f} + b^{2} x + \frac {b^{2} \tan ^{3}{\left (e + f x \right )}}{3 f} - \frac {b^{2} \tan {\left (e + f x \right )}}{f} & \text {for}\: f \neq 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right )^{2} & \text {otherwise} \end {cases} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 382 vs.
\(2 (46) = 92\).
time = 0.64, size = 382, normalized size = 8.30 \begin {gather*} \frac {3 \, a^{2} f x \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 6 \, a b f x \tan \left (f x\right )^{3} \tan \left (e\right )^{3} + 3 \, b^{2} f x \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 9 \, a^{2} f x \tan \left (f x\right )^{2} \tan \left (e\right )^{2} + 18 \, a b f x \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 9 \, b^{2} f x \tan \left (f x\right )^{2} \tan \left (e\right )^{2} - 6 \, a b \tan \left (f x\right )^{3} \tan \left (e\right )^{2} + 3 \, b^{2} \tan \left (f x\right )^{3} \tan \left (e\right )^{2} - 6 \, a b \tan \left (f x\right )^{2} \tan \left (e\right )^{3} + 3 \, b^{2} \tan \left (f x\right )^{2} \tan \left (e\right )^{3} + 9 \, a^{2} f x \tan \left (f x\right ) \tan \left (e\right ) - 18 \, a b f x \tan \left (f x\right ) \tan \left (e\right ) + 9 \, b^{2} f x \tan \left (f x\right ) \tan \left (e\right ) - b^{2} \tan \left (f x\right )^{3} + 12 \, a b \tan \left (f x\right )^{2} \tan \left (e\right ) - 9 \, b^{2} \tan \left (f x\right )^{2} \tan \left (e\right ) + 12 \, a b \tan \left (f x\right ) \tan \left (e\right )^{2} - 9 \, b^{2} \tan \left (f x\right ) \tan \left (e\right )^{2} - b^{2} \tan \left (e\right )^{3} - 3 \, a^{2} f x + 6 \, a b f x - 3 \, b^{2} f x - 6 \, a b \tan \left (f x\right ) + 3 \, b^{2} \tan \left (f x\right ) - 6 \, a b \tan \left (e\right ) + 3 \, b^{2} \tan \left (e\right )}{3 \, {\left (f \tan \left (f x\right )^{3} \tan \left (e\right )^{3} - 3 \, f \tan \left (f x\right )^{2} \tan \left (e\right )^{2} + 3 \, f \tan \left (f x\right ) \tan \left (e\right ) - f\right )}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 12.02, size = 76, normalized size = 1.65 \begin {gather*} \frac {\mathrm {tan}\left (e+f\,x\right )\,\left (2\,a\,b-b^2\right )}{f}+\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (e+f\,x\right )\,{\left (a-b\right )}^2}{a^2-2\,a\,b+b^2}\right )\,{\left (a-b\right )}^2}{f}+\frac {b^2\,{\mathrm {tan}\left (e+f\,x\right )}^3}{3\,f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________